<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\ServicePersonnel;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Illuminate\Support\Facades\Storage;

class ServicePersonnelController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new ServicePersonnel(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('pic')->image('',100,100);
            $grid->column('name');
            $grid->column('work_account','企业微信账号');
            $grid->column('service_time','服务时长');
            $grid->column('desc');
            $grid->column('service_count');
            $grid->column('is_cert')->switch();
//            $grid->column('cert_info');
//            $grid->column('create_time');

            $grid->column('updated_at');

            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');

            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new ServicePersonnel(), function (Show $show) {
            $show->field('id');
            $show->field('pic');
            $show->field('name');
            $show->field('service_time');
            $show->field('desc');
            $show->field('service_count');
            $show->field('is_cert');
            $show->field('cert_info');
            $show->field('create_time');
            $show->field('update_time');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new ServicePersonnel(), function (Form $form) {
            $form->display('id');
            $form->image('pic')->url('files/files');
            $form->text('name');
            $form->number('service_time');
            $form->textarea('desc');
            $form->number('service_count');
            $form->switch('is_cert');
            $form->text('cert_info');
            $form->text('work_account','企业微信账号')->required();
            $form->text('work_qr','企业微信二id');

//            $form->text('create_time');
//            $form->text('update_time');
        });
    }
}
